/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package mylib;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 *
 * @author thang
 */
public class FileHandler {
    
    public static Scanner openFile(String fileName){
        Scanner is = null;
        
        try{
            is = new Scanner(new FileInputStream(fileName));
        }
        catch(FileNotFoundException e){
            System.out.println("Load file error");
            System.exit(0);
        }
        
        return is;
    }
    
    public static PrintWriter openFileToWrite(String fileName){
        PrintWriter os = null;
        
        try{
            os = new PrintWriter(new FileOutputStream(fileName));
        }
        catch(FileNotFoundException e){
            System.out.println("Load file error");
            System.exit(0);
        }
        
        return os;
    }
    
    
}
